package com.itheima.singletontest.service.impl;

import com.itheima.singletontest.dao.StudentDao;
import com.itheima.singletontest.dao.impl.StudentDaoB;
import com.itheima.singletontest.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

/**
 * StudentServiceImpl
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/4/24 9:53
 */
@Scope("singleton")
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public void list() {
        try {
            Thread.sleep(2000);
            String list = studentDao.list();
            System.out.println(list);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void doSomeThing() {
        studentDao = new StudentDaoB();
    }
}
